package com.gg.zjj.service.impl;

import com.gg.common.mapper.MApplyMapper;
import com.gg.common.pojo.MApply;
import com.gg.zjj.service.ProductionPlanReviewService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author koco
 * 2022/10/12
 * 18:16
 */
@Service
public class ProductionPlanReviewServiceImpl implements ProductionPlanReviewService {
    @Resource
    private MApplyMapper applyMapper;
    @Override
    public List<MApply> queryTheProductionPlanToBeReviewed() {
        return applyMapper.queryTheProductionPlanToBeReviewed();
    }

    @Override
    public List<MApply> queryPendingProductionPlanService(String productionPlanNumber) {
        return applyMapper.queryPendingProductionPlanMapper(productionPlanNumber);
    }

    @Override
    public void productionPlanApprovedService(String productionPlanNumber) {
        JSONObject jsonArray1 = JSONObject.fromObject(productionPlanNumber);
        MApply mApply = (MApply) JSONObject.toBean(jsonArray1, MApply.class);
        mApply.setCheckTime(mApply.getCheckTime().replace("T"," "));
        applyMapper.productionPlanApprovedMapper(mApply);
    }

    @Override
    public void productionPlanRejectionService(String productionPlanNumber) {
        JSONObject jsonArray1 = JSONObject.fromObject(productionPlanNumber);
        MApply mApply = (MApply) JSONObject.toBean(jsonArray1, MApply.class);
        mApply.setCheckTime(mApply.getCheckTime().replace("T"," "));
        applyMapper.productionPlanRejectionMapper(mApply);
    }

    @Override
    public List<MApply> queryAllProductionPlansService() {
        return applyMapper.queryAllProductionPlansMapper();
    }

    @Override
    public List<MApply> queryTheCurrentProductionPlanService(String productionPlanNumber) {
        return applyMapper.queryTheCurrentProductionPlanMapper(productionPlanNumber);
    }
}
